JAVA刷题ing
Medium
Given a string, find the length of the longest substring without repeating characters.
Example 1:
1 | Input: "abcabcbb" |
Example 2:
1 | Input: "bbbbb" |
Example 3:
1 | Input: "pwwkew" |
- two point
1 | class Solution { |
Syntax:
1 | Set<Character> mem = new HashSet<Character>(); // correct |
- 关于Hashmap的声明,为什么前面可以是Set后面必须是HashSet,这里。总之,Set包括(HashSet, LinkedHashSet or TreeSet)前面是对对象类型的声明,类型可以是总的,或者是具体的,但后面是调用接口,对对象初始化,这里就没有set这一选项了。
1 | System.out.println("d"+mem+s.charAt(j)); |
- debug必备。print don’t change the line, but println (means print line next) change line after printing. using ‘+’ to link two string. ‘ ‘ can only be used to one char, “ “ can be used to string.